/**
 * 扩展nullwork方法
 * noNull:不是空的时候执行
 * isNull:为空的时候执行
 *
 */
inline fun <T, R> T?.nullWork(noNull: (T) -> R, isNull: () -> R): R {
    return this?.let {
        return when (it) {
            is Collection<*> -> if (it.isNotEmpty()) noNull(it) else isNull()
            is String -> if (it.isNotEmpty()) noNull(it) else isNull()
            else -> {
                noNull(it)
            }
        }
    } ?: isNull()
}

/**
 * 不为空
 */
inline fun <T, R> T?.notNull(noNull: (T) -> R) {
    this?.let {
        when (it) {
            is Collection<*> -> if (it.isNotEmpty()) noNull(it) else {
            }
            is String -> if (it.isNotEmpty()) noNull(it) else {
            }
            else -> {
                noNull(it)
            }
        }
    }
}